home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12809 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  78 lines

  1. Path: news.simi.is!newsadm
  2. From: Bj÷rn Helgason <bjornhp@simi.is>
  3. Newsgroups: comp.lang.misc,comp.lang.c,comp.lang.pl1,comp.lang.apl
  4. Subject: Re: GOTO controversy
  5. Date: Tue, 02 Apr 1996 18:53:25 +0000
  6. Organization: Post and Telecom Iceland, IS-150 Reykjavik, ICELAND
  7. Message-ID: <316177A5.4005@simi.is>
  8. References: <314FB5F5.259B@simi.is> <3151B47F.70FD@connix.com>
  9. NNTP-Posting-Host: simi.is
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win95; I)
  14.  
  15. Scott Hawley wrote:
  16. > What to you think? Loops without using loops?
  17. > a loop:
  18. > for(i=0;i<10;i++)
  19. > {
  20. >   stuff
  21. > }
  22. > Looping with out a loop
  23. > no_loop(0,10);
  24. > no_loop(int start, int end)
  25. > {
  26. >     if(start != end) {
  27. >         stuff
  28. >         no_loop(start+1,end);
  29. >     }
  30. > }
  31. > I haven't tested this but you get the idea.
  32.  
  33. In J I frequently use something like 
  34.  
  35. empty  keyra each vector
  36.  
  37. where vector contains number of elements which may or may not be 
  38. referenced in the verb keyra or subsequently called verbs. Its size
  39. is used as a counter.
  40.  
  41. vector could look like this:
  42.  
  43. vector=.i.111
  44.  
  45. Keyra could look like this:
  46.  
  47. keyra=: 3 : 0
  48. try. runni ''
  49. catch. empty''
  50. end.
  51. )
  52.  
  53. each makes the verb keyra be called as many times as there are elements
  54. in vector. 
  55.  
  56. empty makes sure I do not get any display of any results.
  57.  
  58. each and empty are utilty verbs in J
  59.  
  60. runni is a verb called by keyra and is actually the one I want to 
  61. call but if it breaks down somewhere I dont want the operation to
  62. halt but to continue with the next element of vector.
  63.  
  64. I do not specify any start nor end
  65.  
  66.  
  67. -- 
  68. /Gosi , bjornhp@simi.is 
  69. http://www2.simi.is/~gosi
  70. http://www.jsoftware.com
  71.